package tree;

import java.util.HashMap;

public class TrieTree {
    private boolean isWord = false;
    private HashMap<Character, TrieTree> map = new HashMap<>();

    public void insert(String str , TrieTree trieTree){
        if(str == null || str.length() == 0){
            return;
        }

        char[] c = str.toCharArray();
        int i = 0;
        TrieTree cur = trieTree;
        while (i < c.length){
            if(!cur.map.containsKey(c[i])){
                cur.map.put(c[i],new TrieTree());
            }
            cur = cur.map.get(c[i]);
            i++;
        }
        cur.isWord = true;
    }

    public HashMap<Character, TrieTree> getMap() {
        return map;
    }

    public void setMap(HashMap<Character, TrieTree> map) {
        this.map = map;
    }
}
